export default {
  localDateFormat(originVal) {
    if (originVal === null) {
      return null
    }
    const year = originVal[0]
    const month = (originVal[1] + '').padStart(2, '0')
    const day = (originVal[2] + '').padStart(2, '0')
    return `${year}-${month}-${day} `
  },

  localDateTimeFormat(originVal) {
    const year = originVal.year
    const month = (originVal.monthValue + '').padStart(2, '0')
    const day = (originVal.dayOfMonth + '').padStart(2, '0')

    const hh = (originVal.hour + '').padStart(2, '0')
    const mm = (originVal.minute + '').padStart(2, '0')
    const ss = (originVal.second + '').padStart(2, '0')
    return `${year}-${month}-${day} ${hh}:${mm}:${ss}`
  },

  dateTimeFormat(originVal) {
    const dt = new Date(originVal)
    const year = dt.getFullYear()
    const month = (dt.getMonth() + 1 + '').padStart(2, '0')
    const day = (dt.getDate() + '').padStart(2, '0')

    const hh = (dt.getHours() + '').padStart(2, '0')
    const mm = (dt.getMinutes() + '').padStart(2, '0')
    const ss = (dt.getSeconds() + '').padStart(2, '0')
    return `${year}-${month}-${day} ${hh}:${mm}:${ss}`
  },
  dateFormat(originVal) {
    const dt = new Date(originVal)
    const year = dt.getFullYear()
    const month = (dt.getMonth() + 1 + '').padStart(2, '0')
    const day = (dt.getDate() + '').padStart(2, '0')

    return `${year}-${month}-${day} `
  },

  clear(data) {
    for (const key in data) {
      data[key] = null
    }
  }
}
